package com.suixingpay.seckill.controller;

import com.suixingpay.seckill.pojo.Activity;
import com.suixingpay.seckill.pojo.Result;
import com.suixingpay.seckill.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;

import static com.suixingpay.seckill.util.ParamCheck.paramCheck;

@Controller
@RequestMapping("/activity")
public class ActivityController {
    @Autowired
    ActivityService activityService;
    Result result = new Result();


    @PostMapping("/insertAct")
    public Result insertAct(@RequestBody Activity activity) {
        if (!paramCheck(activity.getActivityName(),activity.getActivityProvince(), activity.getActivityBegin(), activity.getActivityEnd(), activity.getActivityNum())) {
            result.set(400,"不能输入空数据！",null);
            return result;
        }
        return activityService.insertAct(activity);
    }

}
